from django.contrib import admin
from django.urls import path, include
from rest_framework.routers import DefaultRouter
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView
from rest_framework_simplejwt.views import (
    TokenObtainPairView,
    TokenRefreshView,
)
from django.conf import settings
from django.conf.urls.static import static
from django_ckeditor_5 import urls as ckeditor5_urls

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('django_txlapp.urls')),  # 通讯录应用的普通路由
    path('article/', include('django_article_app.urls')),  # 文章应用的普通路由
    path('ckeditor5/', include(ckeditor5_urls)),

    # API路由 - 为不同应用设置不同前缀
    path('api/txl/', include('django_txlapp.api_urls')),  # 通讯录应用的API路由
    path('api/article/', include('django_article_app.api_urls')),  # 文章应用的API路由
    
    # 文档和认证路由
    path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
    path('api/', SpectacularSwaggerView.as_view(url_name='schema'), name='swagger-ui'),
    path('api/token/', TokenObtainPairView.as_view(), name='token_obtain_pair'),
    path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'),
]  + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) # 配置媒体文件路由
